package com.shengwei.truck.driver.vm;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.shengwei.truck.driver.bean.Result;
import com.shengwei.truck.driver.model.DataSource;
import com.shengwei.truck.driver.model.Repository;

/**
 * 修改手机号码
 */
public class ModifyMobileViewModel extends ViewModel {
    private Repository mRepository; //M层引用
    MutableLiveData<Result<String>> smsCodeData = new MutableLiveData<>();
    MutableLiveData<Result<String>> modifyMobileData = new MutableLiveData<>();


    public MutableLiveData<Result<String>> getSmsCodeData() {
        return smsCodeData;
    }
    public MutableLiveData<Result<String>> getModifyMobileData() {
        return modifyMobileData;
    }

    public ModifyMobileViewModel(Repository repository) {
        mRepository = repository;
    }

    public ModifyMobileViewModel() {
        mRepository = Repository.getInstance(DataSource.getSingleInstance());
    }

    /**获取短信验证码
     * VM层调用M层（Repository+DataSource）
     * @param mobileNum：新手机号
     * @param pageType : UPDATE_PHONE(修改手机号),USER_REGISTER(注册页面),FORGET_PASSWORD（忘记密码页面）,CHANGE_PASSWORD（修改密码页面）
     * @return
     */
    public void getSmsCode(String mobileNum,String pageType) {
          mRepository.getSmsCode(mobileNum,pageType,smsCodeData);
    }

    /**
     * @param identify: 身份证号
     * @param mobileNum： 新手机号
     * @param captcha： 验证码
     */
    public void updateMobile(String identify,String mobileNum,String captcha) {
        mRepository.updateMobile(identify,mobileNum,captcha,modifyMobileData);
    }
}